package controller.web;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import business.Obat;
import business.ObatListing;
import business.User;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

public class ObatListingServlet extends Servlet {
    private User user;

    public ObatListingServlet() {
        super();
        setTemplate("/WEB-INF/listObat.jsp");
    }

    @Override
    protected void process() {
      setMessage("");
        ObatListing dl = new ObatListing();
        if(validate_Obat()){
            List<Obat> i = dl.obatTerbaru();
            getRequest().setAttribute("obatList", i.iterator());
        }
        else{
            try {
                getResponse().sendRedirect("ObatListKosong");
            } catch (IOException ex) {
                Logger.getLogger(ObatListingServlet.class.getName()).log(Level.SEVERE, null, ex);
            }

            }
        }

    private boolean validate_Obat(){
        ObatListing dl = new ObatListing();
        int xx = dl.getJumlahObat();

        if( xx == 0){
            return false;
        }

        return true;
    }
}

